package mc.web.validators;

import mc.domain.Pacjent;
import mc.util.CheckFieldsValues;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

public class PacjentWyszukiwarkaValidator implements Validator{

	public boolean supports(Class arg0) {
		return arg0.equals(Pacjent.class);
	}

	public void validate(Object arg0, Errors errors) {
		
		Pacjent p = (Pacjent) arg0;
		
		
		try {
			if((CheckFieldsValues.hasAllNullStringValues(p))&&(CheckFieldsValues.hasAllNullStringValues(p.getAdresy().get(0)))){
				
				errors.reject("search.allfields.empty");
				
				
			}
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

}
